import { message } from 'antd';
import React, { useRef } from 'react';
import ReactWEditor from 'wangeditor-for-react';

const IctEditor = () => {
  let editorRef = useRef(null);

  return (
    <ReactWEditor
      ref={editorRef}
      config={{
        lang: 'en',
        height: 500,
        menuTooltipPosition: 'down',
        uploadImgServer: `${import.meta.env.VITE_APP_BASE_API}/v1/system/resource/upload`,
        uploadImgShowBase64: true,
        customAlert: (s: string, t: string) => {
          switch (t) {
            case 'success':
              message.success(s);
              break;
            case 'info':
              message.info(s);
              break;
            case 'warning':
              message.warning(s);
              break;
            case 'error':
              message.error(s);
              break;
            default:
              message.info(s);
              break;
          }
        },
      }}
    />
  );
};

export default IctEditor;
